package vip.xiaonuo.modular.controller;

import vip.xiaonuo.core.annotion.BusinessLog;
import vip.xiaonuo.core.annotion.Permission;
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum;
import vip.xiaonuo.core.pojo.page.PageResult;
import vip.xiaonuo.core.pojo.response.ResponseData;
import vip.xiaonuo.core.pojo.response.SuccessResponseData;
import vip.xiaonuo.modular.entity.Kaochang;
import vip.xiaonuo.modular.param.KaochangParam;
import vip.xiaonuo.modular.service.KaochangService;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.util.List;

/**
 * 考场管理控制器
 *
 * @author 春非昔日春
 * @date 2023-02-28 13:16:01
 */
@Controller
public class KaochangController {

    private String PATH_PREFIX = "kaochang/";

    @Resource
    private KaochangService kaochangService;

    /**
     * 考场管理页面
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01
     */
    @Permission
    @GetMapping("/kaochang/index")
    public String index() {
        return PATH_PREFIX + "index.html";
    }

    /**
     * 考场管理表单页面
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01
     */
    @GetMapping("/kaochang/form")
    public String form() {
        return PATH_PREFIX + "form.html";
    }

    /**
     * 查询考场管理
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01
     */
    @Permission
    @ResponseBody
    @GetMapping("/kaochang/page")
    @BusinessLog(title = "考场管理_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public PageResult<Kaochang> page(KaochangParam kaochangParam) {
        return kaochangService.page(kaochangParam);
    }

    /**
     * 添加考场管理
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01
     */
    @Permission
    @ResponseBody
    @PostMapping("/kaochang/add")
    @BusinessLog(title = "考场管理_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(KaochangParam.add.class) KaochangParam kaochangParam) {
        kaochangService.add(kaochangParam);
        return new SuccessResponseData();
    }

    /**
     * 删除考场管理
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01
     */
    @Permission
    @ResponseBody
    @PostMapping("/kaochang/delete")
    @BusinessLog(title = "考场管理_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(KaochangParam.delete.class) List<KaochangParam> kaochangParamList) {
        kaochangService.delete(kaochangParamList);
        return new SuccessResponseData();
    }

    /**
     * 编辑考场管理
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01
     */
    @Permission
    @ResponseBody
    @PostMapping("/kaochang/edit")
    @BusinessLog(title = "考场管理_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(KaochangParam.edit.class) KaochangParam kaochangParam) {
        kaochangService.edit(kaochangParam);
        return new SuccessResponseData();
    }

    /**
     * 查看考场管理
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01
     */
    @Permission
    @ResponseBody
    @GetMapping("/kaochang/detail")
    @BusinessLog(title = "考场管理_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(KaochangParam.detail.class) KaochangParam kaochangParam) {
        return new SuccessResponseData(kaochangService.detail(kaochangParam));
    }

    /**
     * 考场管理列表
     *
     * @author 春非昔日春
     * @date 2023-02-28 13:16:01u
     */
    @Permission
    @ResponseBody
    @GetMapping("/kaochang/list")
    @BusinessLog(title = "考场管理_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(KaochangParam kaochangParam) {
        return new SuccessResponseData(kaochangService.list(kaochangParam));
    }

}
